class CreateCategories < ActiveRecord::Migration
  def change
    create_table :categories, :force => true do |t|
      t.references :category_group,        :null => false
      t.string  :presentation, :limit => 30,  :null => false
      t.string  :headline,  :limit => 60,  :null => true
      t.string  :url,       :limit => 30,  :null => false
      t.string  :permalink, :limit => 100, :null => false #complete url address
      t.string  :title,     :limit => 250, :null => true
      t.text    :description,              :null => true
      t.string  :listing_type, :limit => 20, :null => true, :default => "with_images"

      #Acts_as_nested_set
      t.integer :parent_id,   :limit => 4
      t.integer :lft,  :limit => 4, :null => false
      t.integer :rgt, :limit => 4, :null => false
      t.boolean :hidden, :default => 0

      t.timestamps
    end

      add_index :categories, :url
      add_index :categories, :permalink, :unique => true
      add_index :categories, :category_group_id
      add_index :categories, :parent_id
      add_index :categories, :lft
      add_index :categories, :rgt
  end
end